<template>
	<view class="pro_content">
		<view class="pro_title">{{proData.noticeTitle}}</view>
		<view class="pro_time">
			<text>Announcement release time：{{proData.createTime}}</text>
		</view>
		<view class="pro_text">{{proData.noticeContent}}</view>
		<view class="pro_author">
			<text>Announcer：{{proData.createName}}</text>
		</view>
	</view>
</template>

<script>
	import api from '../../api/proclamationApi.js'
	import otherApi from '../../api/otherApi.js'
	import utils from '../../api/utils.js'
	export default {
		data() {
			return {
				proData: {}
			}
		},
		async onLoad(option) {
			let _this = this
			let token = ""
			uni.showLoading({
				title: 'Please wait...',
				mask: true
			});
			uni.getStorage({
				key: 'token',
				success(res) {
					token: res.data
				}
			})
			if (utils.userType == '学生' && utils.platform == 'android') {
				uni.getLocation({
					type: 'wgs84',
					geocode: true,
					async success(res) {
						let Position = {};
						Position = {
							address: (res.address.country + res.address.province + res.address.city + res.address.district + res.address.street + res.address.streetNum).replace(
								/undefined/g,
								''
							),
							latitude: res.latitude,
							longitude: res.longitude
						};
						let savePosition = await otherApi.savePosition('position/savePosition', Position, token);
					}
				});
				setInterval(async () => {
					let Position = {};
					uni.getLocation({
						type: 'wgs84',
						geocode: true,
						async success(res) {
							let Position = {};
							Position = {
								address: (res.address.country + res.address.province + res.address.city + res.address.district + res.address.street + res.address.streetNum).replace(
									/undefined/g,
									''
								),
								latitude: res.latitude,
								longitude: res.longitude
							};
							await otherApi.savePosition('position/savePosition', Position, token);
						}
					});
				}, 900000);
			}
			let data = await api.getProDetails(`notice/getGruSysNotice?noticeId=${option.id}`, token)
			console.log(data)
			if (data.head.status) {
				_this.proData = data.body
			} else {
				uni.showToast({
					title: data.head.msg,
					icon: 'none',
					duration: 2000
				});
			}
			uni.hideLoading()
		}
	}
</script>

<style scoped>
	.pro_content {
		width: 100%;
		padding: 15px 30px 20px 30px;
	}
	
	.pro_title {
		width: 100%;
		font-size: 22px;
		color: #333;
		text-align: center;
		margin-bottom: 15px;
	}
	
	.pro_time {
		margin-bottom: 20px;
	}
	
	.pro_time > text {
		color: #999;
		font-size: 12px;
	}
	
	.pro_text {
		text-indent: 2em;
		color: #555;
		letter-spacing: 2px;
	}
	
	.pro_author {
		margin-top: 30px;
		text-align: right;
		color: #999;
		font-size: 14px;
	}
</style>
